<?php
namespace app\admin\model;

use think\Model;

class BusChannelSimConfig extends Model
{
    public function getListAll($request)
    {
        $data = $this->alias('bsc')
        ->field('bsc.*
        	, concat( bus_channel.channel_id , "/", bus_channel.company_name ) as company_name
        	, concat( pla.plat_id , "/", pla.platfrom ) as platfrom
        	, concat( bf_p.plat_id , "/", bf_p.platfrom ) as bf_platfrom
        	, concat( zw_p.plat_id , "/", zw_p.platfrom ) as zw_platfrom
        	')
        ->join('bus_platfrom pla'  , 'bsc.plat_id = pla.plat_id','left')
        ->join('bus_platfrom bf_p' , 'bsc.bf_plat_id = bf_p.plat_id','left')
        ->join('bus_platfrom zw_p' , 'bsc.zw_plat_id = zw_p.plat_id','left')
        ->join('bus_channel' , 'bsc.cid = bus_channel.channel_id','left')
        ->order('bus_channel.channel_id desc , id')
        ->paginate($request['limit'])
        ->toarray();

        foreach ($data['data'] as $key => $value) {
            switch ($value['bf_onoff']) {
                case '0':
                    $data['data'][$key]['bf_onoff'] = '<span style="color:red">关闭</span>';
                    break;
                case '1':
                    $data['data'][$key]['bf_onoff'] = '<span style="color:green">开启</span>';
                    break;

                default:
                    $data['data'][$key]['bf_onoff'] = '<span style="color:red">关闭</span>';
                    break;
            }
            switch ($value['zw_onoff']) {
                case '0':
                    $data['data'][$key]['zw_onoff'] = '<span style="color:red">关闭</span>';
                    break;
                case '1':
                    $data['data'][$key]['zw_onoff'] = '<span style="color:green">开启</span>';
                    break;

                default:
                    $data['data'][$key]['zw_onoff'] = '<span style="color:red">关闭</span>';
                    break;
            }
            switch ($value['bf_plat_index_onoff']) {
                case '0':
                    $data['data'][$key]['bf_plat_index_onoff'] = '<span style="color:red">关闭</span>';
                    break;
                case '1':
                    $data['data'][$key]['bf_plat_index_onoff'] = '<span style="color:green">开启</span>';
                    break;

                default:
                    $data['data'][$key]['bf_plat_index_onoff'] = '<span style="color:red">关闭</span>';
                    break;
            }
            switch ($value['zw_plat_index_onoff']) {
                case '0':
                    $data['data'][$key]['zw_plat_index_onoff'] = '<span style="color:red">关闭</span>';
                    break;
                case '1':
                    $data['data'][$key]['zw_plat_index_onoff'] = '<span style="color:green">开启</span>';
                    break;

                default:
                    $data['data'][$key]['zw_plat_index_onoff'] = '<span style="color:red">关闭</span>';
                    break;
            }
            switch ($value['isp_host']) {
                case '10086':
                    $data['data'][$key]['isp_host'] = '中国移动';
                    break;
                case '10010':
                    $data['data'][$key]['isp_host'] = '中国联通';
                    break;
                case '10000':
                    $data['data'][$key]['isp_host'] = '中国电信';
                    break;

                default:
                    # code...
                    break;
            }
            switch ($value['onoff']) {
                case '0':
                    $data['data'][$key]['onoff'] = '<span style="color:red">关闭</span> / '.$data['data'][$key]['bf_onoff'].' / '.$data['data'][$key]['bf_plat_index_onoff'].' / '.$data['data'][$key]['zw_onoff'].' / '.$data['data'][$key]['zw_plat_index_onoff'];
                    $data['data'][$key]['onoff_btn'] = '<a class="javascript:;" title="开关" lay-event="onoff">开</a>';
                    break;
                case '1':
                    $data['data'][$key]['onoff'] = '<span style="color:green">开启</span> / '.$data['data'][$key]['bf_onoff'].' / '.$data['data'][$key]['bf_plat_index_onoff'].' / '.$data['data'][$key]['zw_onoff'].' / '.$data['data'][$key]['zw_plat_index_onoff'];
                    $data['data'][$key]['onoff_btn'] = '<a class="javascript:;" title="开关" lay-event="onoff">关</a>';
                    break;

                default:
                    # code...
                    break;
            }


        }

        return $data;

    }
}